package com.hanthink.web.controller.manhour;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.system.domain.manhour.FactWorkerUsed;
import com.hanthink.system.service.manhour.IFactWorkerUsedService;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 实际用工数据维护Controller
 * 
 * @author hanthink
 * @date 2022-01-05
 */
@RestController
@RequestMapping("/manhour/FactWorkerUsed")
public class FactWorkerUsedController extends BaseController
{
    @Autowired
    private IFactWorkerUsedService factWorkerUsedService;

    /**
     * 查询实际用工数据维护列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:list')")
    @GetMapping("/list")
    public TableDataInfo list(FactWorkerUsed factWorkerUsed)
    {
        startPage();
        List<FactWorkerUsed> list = factWorkerUsedService.selectFactWorkerUsedList(factWorkerUsed);
        return getDataTable(list);
    }

    /**
     * 导出实际用工数据维护列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:export')")
    @Log(title = "实际用工数据维护", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FactWorkerUsed factWorkerUsed)
    {
        List<FactWorkerUsed> list = factWorkerUsedService.selectFactWorkerUsedList(factWorkerUsed);
        ExcelUtil<FactWorkerUsed> util = new ExcelUtil<FactWorkerUsed>(FactWorkerUsed.class);
        return util.exportExcel(list, "FactWorkerUsed");
    }

    /**
     * 获取实际用工数据维护详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(factWorkerUsedService.selectFactWorkerUsedById(id));
    }

    /**
     * 新增实际用工数据维护
     */
    @PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:add')")
    @Log(title = "实际用工数据维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FactWorkerUsed factWorkerUsed)
    {
        return toAjax(factWorkerUsedService.insertFactWorkerUsed(factWorkerUsed));
    }

    /**
     * 修改实际用工数据维护
     */
    @PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:edit')")
    @Log(title = "实际用工数据维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FactWorkerUsed factWorkerUsed)
    {
        return toAjax(factWorkerUsedService.updateFactWorkerUsed(factWorkerUsed));
    }

    /**
     * 删除实际用工数据维护
     */
    @PreAuthorize("@ss.hasPermi('manhour:FactWorkerUsed:remove')")
    @Log(title = "实际用工数据维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(factWorkerUsedService.deleteFactWorkerUsedByIds(ids));
    }
}
